<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //匹配url的路径
        var reg = /http:(\/\/.+\.jpg)/
        var str = 'http://img.host.com/abc.jpg'.replace(reg,'$1')
        console.log(str)////img.host.com/abc.
        //匹配时间日期格式
        // var reg = /^\d{4}[-/]\d{1,2}[-/]\d{1,2}$/
        //  console.log(reg.test('2016-11-11'))
        //  console.log(reg.test('2016/11/11'))

        //将日期格式匹配为年月日
    //    var reg = /^(\d{4})[-/](\d{1,2})[-/](\d{1,2})$/
    //     var str = '2016-11-11'
    //     var dateStr = str.replace(reg,'$1年$2月$3日')
    //     console.log(dateStr)
        
        //如何将'123456'转成货币带逗号的。'123,456'
        console.log('123456789'.replace(/(d)(?=(?:d{3})+$)/g, '$1,'))
        

    </script>
</body>
</html>